<template>
	<view class="page">
		<view class="row">
			<view class="label">
				更换绑定情况:
			</view>
			<view class="input">
				使用原有手机号更换新手机号
			</view>
		</view>
		<view class="row">
			<view class="label">
				原手机号:
			</view>
			<view class="input">
				<u-input type="number" v-model="form.parent1" placeholder="请输入原手机号"></u-input>
			</view>
		</view>
		<view class="row">
			<view class="label">
				新手机号:
			</view>
			<view class="input">
				<u-input type="number" v-model="form.phone" placeholder="请输入新手机号"></u-input>
			</view>
		</view>
		<!-- <view class="row">
			<view class="label">
				验证码:
			</view>
			<view class="input">
				<u-input type="number" v-model="form.changecode" placeholder="请输入验证码"></u-input>
				<view class="getCodeBtn" @click="sendCode">
					{{sendText}}
				</view>
			</view>
		</view> -->
		<view class="btn" @click="handleConfirm">
			<text>确定</text>
		</view>
		
	</view>
</template>

<script>
	import {sendsmsApi,editPhoneApi} from '@/common/api/commonApi/commonApi.js'
	export default {
		data() {
			return {
				form:{
					parent1: '',
					phone : '',
					id :''
				},
				sendText: '获取验证码',
				
			}
		},
		methods: {
			sendCode(){
				if(!this.form.newPhone) return this.setMessage('新手机号不能为空')
				sendsmsApi({
					mainframeNo:  this.form.mainframeNo,
					memberId: this.form.memberId,
					smsType:  '2',
					iphone: this.form.newPhone,
				}).then(res=>{
					this.sendText = '重新发送'
					this.setMessage('发送成功！')
				})
			},
			handleSendCode(type){
					let bool = uni.$u.test.mobile(this.form.mobilephone)
					this.sendText = '重新获取验证码'
			},
			handleConfirm(){
				if(!this.form.parent1) return this.setMessage('原手机号不能为空')
				if(!this.form.phone) return this.setMessage('新手机号不能为空')
				if(this.form.parent1==this.form.phone) return this.setMessage('新旧手机号不能相同')
				editPhoneApi(this.form).then(res=>{
					this.setMessage('操作成功')
					setTimeout(()=>{
						this.goBack()
					},1500)
				})
			}
		},
		onLoad() {
			let info = uni.getStorageSync('selectInfoAccount')
			this.form.id = info.id
		},
		onShow() {
			
		},
	}
</script>

<style lang="scss" scoped>
.page{
	background-color: #fff;
	height: 100vh;
	.text{
		color: #333;
	}
	.row{
		display: flex;
		align-items: center;
		height: 90rpx;
		padding: 0 30rpx;
		border-bottom: 2rpx solid #dcdcdc;
		&:nth-child(1){
			border-top: 2rpx solid #dcdcdc;
		}
		.label{
			width: 220rpx;
		}
		.input{
			flex: 1;
			height: 100%;
			display: flex;
			align-items: center;
			.getCodeBtn{
				background-color: #4089f0;
				@include flexCenter;
				color: #fff;
				border-radius: 40rpx;
				height: 52rpx;
				width: 182rpx;
			}
		}
		
	}
	.btn{
		margin: 20rpx auto 0;
		background: #2d8cf6;
		@include flexCenter;
		width: 90vw;
		height: 92rpx;
		border-radius: 10rpx;
		text{
			color: #fff;
		}
	}
	
}
</style>
